import com.sun.org.apache.bcel.internal.classfile.InnerClass;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;

class OuterClass{
    public int a = 1;
    private int b = 2;
    public static int c = 3;
    static class InnerClass {
        public int d = 4;
        private int e = 5;
        public static int f = 6;

        public void func(){
            System.out.println("static->InnerClass::func");
            OuterClass outerClass = new OuterClass();
            System.out.println(outerClass.a);
            System.out.println(outerClass.b);
            System.out.println(c);
            System.out.println(d);
            System.out.println(e);
            System.out.println(f);
        }
    }


    public void outerFunc(){
        System.out.println("OuterClass::outerFunc");
        InnerClass innerClass = new InnerClass();
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(innerClass.d); //d 为静态内部类非静态成员变量
        System.out.println(innerClass.e); //e 为静态内部类非静态成员变量
        System.out.println(InnerClass.f); //f 是静态内部类的静态成员变量，通过类名便可访问
    }
}

class OuterClass1{
    public int a = 1;
    private int b = 2;
    public static int c = 3;
    class InnerClass1{
        public int d = 4;
        private int e = 5;
        public static final int f = 6;
        public void func(){
            System.out.println("InnerClass1::func");
            System.out.println(a);
            System.out.println(b);
            System.out.println(c);
            System.out.println(d);
            System.out.println(e);
            System.out.println(f);
        }
    }
    public void func1(){
        System.out.println("OuterClass1::func1");
        InnerClass1 innerClass1 = new InnerClass1();
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(innerClass1.d);
        System.out.println(innerClass1.e);
        System.out.println(innerClass1.f);
    }
}

class OuterClass2{
    public int a = 4;
    class InnerClass2{
        public int a = 444444;
        public void func(){
            System.out.println(a);
            System.out.println(OuterClass2.this.a);
        }
    }
}

class OutClass3{
    public void func(){
            class InnerClass3{
                public int a = 8;
                public void fun(){
                    System.out.println("hello!");
                }
        }
        InnerClass3 innerClass3 = new InnerClass3();
            innerClass3.fun();
    }
}

interface IA{
    void func();
}

class AA implements IA{
    public void func(){
        System.out.println("hehehe");
    }
}
public class Text {
    public static void main(String[] args) {
        new IA(){
            @Override
            public void func() {
                System.out.println("呜呜呜~");
            }
        }.func();
    }
    public static void main11(String[] args) {
        IA ia = new AA();
        ia.func();
    }
    public static void main10(String[] args) {
        OutClass3 outClass3 = new OutClass3();
        outClass3.func();
    }
    public static void main9(String[] args) {
        OuterClass2 outerClass2 = new OuterClass2();
        OuterClass2.InnerClass2 innerClass2 = outerClass2.new InnerClass2();
        innerClass2.func();
    }
        public static void main8(String[] args) {
            OuterClass1 outerClass = new OuterClass1();
            OuterClass1.InnerClass1 innerClass1 = outerClass.new InnerClass1();
            innerClass1.func();
        }
    public static void main7(String[] args) {
        //实例化一个内部类对象；
        OuterClass.InnerClass innerClass = new OuterClass.InnerClass();
        innerClass.func();
    }
    public static int removeDuplicates(int[] nums) {
        int end = nums.length - 1;
        int i = 0;
        while(i < end){
            if(nums[i] == nums[i+1]){
                System.arraycopy(nums,i+1,nums,i,nums.length-(i+1));
                end--;
            }else{
                i++;
            }
        }
        for (int j = 0; j < end + 1; j++) {
            System.out.print(nums[j]+" ");
        }

        return end + 1;
    }

    public static void main6(String[] args) {
        int[] arr = {1,1,2,2,2,2,2,5,5,7,8,22,22,67};
        int ret = removeDuplicates(arr);
        System.out.println(ret);
    }
    public static void main5(String[] args) {
        int[] arr = {1,2,3,3,44,5};
        System.arraycopy(arr,1,arr,3,3);
        System.out.println(Arrays.toString(arr));
    }
    public static void main4(String[] args) {
        List<Integer> arrayList = new ArrayList<>();
        arrayList.add(100);
        arrayList.add(101);
        arrayList.add(102);
        arrayList.add(103);
        ListIterator<Integer> iterator = arrayList.listIterator();
        while(iterator.hasNext()){
            System.out.print(iterator.next()+" ");
        }
    }
    public static void main3(String[] args) {
        List<String> arrayList = new ArrayList<>();
        arrayList.add("Romeo");
        arrayList.add(" and ");
        arrayList.add("Juliet");
        for(String x:arrayList){
            System.out.print(x);
        }
    }
    public static void main2(String[] args) {
        List<Character> arrayList = new ArrayList<>();
        arrayList.add('S');
        arrayList.add('O');
        arrayList.add('S');
        for (int i = 0; i < arrayList.size(); i++) {
            System.out.print(arrayList.get(i)+" ");
        }
    }
    public static void main1(String[] args) {

        List<String> arrayList = new ArrayList<>();
        //尾插：
        arrayList.add("trees");
        arrayList.add("the sun");
        //指定位置插入元素：
        arrayList.add(1,"flowers");
        //尾插 List 类型 list 对象中的元素：
        List<String> list = new ArrayList<>();
        list.add("blue sky");
        list.add("birds");
        list.add("grass");
        arrayList.addAll(list);
        System.out.println(arrayList);
        //获取某下标的元素：
        System.out.println(arrayList.get(0));
        //将某下标的元素设置成输入元素:
        arrayList.set(0,"forests");
        System.out.println(arrayList);
        //删除指定下标的元素：
        arrayList.remove(2);
        System.out.println(arrayList);
        //删除首个输入的元素：
        arrayList.remove("blue sky");
        System.out.println(arrayList);
        //判断某元素是否在 arraylist 中：
        System.out.println(arrayList.contains("grass"));
        //返回首个输入元素的下标：
        System.out.println(arrayList.indexOf("birds"));
    }
}
